package br.com.felipe.agendamento.utils.serializer;

import java.io.IOException;
import java.util.ArrayList;

import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;

import br.com.felipe.agendamento.entity.EmailDto;

public class JsonListSerializer extends JsonSerializer<ArrayList<EmailDto>> {

	@Override
	public void serialize(ArrayList<EmailDto> email, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {

		if(email != null){

			for(EmailDto e : email){
				
				if(e.getPessoaDto() != null){
					e.getPessoaDto().setListaEmail(null); 
				}
				//e.setPessoaDto(null);
			}
			jgen.writeObject(email);
			
		}else{
			jgen.writeNull();
		}
		System.out.println("teste");

	}

}
